<?php
namespace app\admin\model\Auth;

use support\Model;


class AdminModel extends Model
{
    protected $name = "system_admin";

    protected $pk = "id";


    /**
     * 是否为超级管理员
     */
    const IS_SUPER_FALSE = 0;//否
    const IS_SUPER_TRUE = 1;//是


    /**
     * 登录判断
     * @param string $username
     * @param string $password
     * @return AdminModel|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @return array|null|\think\Model
     */
    public function login(string $username , string $password):?AdminModel
    {
        $userInfo = $this->where([ 'username' => $username ])->find();
        if(!empty($userInfo) && md5($password . $userInfo->salt) === $userInfo->password){
            return $userInfo;
        }
        return null;
    }


}